<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta charset="utf-8" />
<title>驴妈妈统计系统</title>
<meta name="description" content="overview &amp; stats" />
<meta name="viewport"
	content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
<!-- bootstrap & fontawesome -->
<link rel="stylesheet"
	href="${request.contextPath}/static/assets/css/bootstrap.css">
<link rel="stylesheet"
	href="${request.contextPath}/static/assets/font-awesome/4.5.0/css/font-awesome.min.css">
<!-- page specific plugin styles -->
<link rel="stylesheet"
	href="${request.contextPath}/static/assets/css/daterangepicker.min.css">

<link rel="stylesheet"
	href="${request.contextPath}/static/assets/css/jquery.gritter.min.css" />
<!-- text fonts -->
<link rel="stylesheet"
	href="${request.contextPath}/static/assets/css/fonts.googleapis.com.css" />

<!-- text fonts -->
<link rel="stylesheet"
	href="${request.contextPath}/static/assets/css/fonts.css">
<!-- ace styles -->
<link rel="stylesheet"
	href="${request.contextPath}/static/assets/css/ace.min.css"
	class="ace-main-stylesheet" id="main-ace-style">
<link rel="stylesheet"
	href="${request.contextPath}/static/assets/css/ace-skins.min.css">
<link rel="stylesheet"
	href="${request.contextPath}/static/assets/css/ace-rtl.min.css">
<!-- ace settings handler -->
<script src="${request.contextPath}/static/assets/js/ace-extra.min.js"></script>
<link rel="stylesheet"
	href="${request.contextPath}/static/assets/css/bootstrap-datepicker3.min.css">
<script src="${request.contextPath}/assets/js/jquery-2.1.4.min.js"></script>
<style>
 .page-content{padding: 0px 0px 0px!important;}
 .ace-icon{cursor: pointer;}
@
keyframes nodeInserted {
	from {outline-color: #fff
}

to {
	outline-color: #000
}

}
@
-moz-keyframes nodeInserted {
	from {outline-color: #fff
}

to {
	outline-color: #000
}

}
@
-webkit-keyframes nodeInserted {
	from {outline-color: #fff
}

to {
	outline-color: #000
}

}
@
-ms-keyframes nodeInserted {
	from {outline-color: #fff
}

to {
	outline-color: #000
}

}
@
-o-keyframes nodeInserted {
	from {outline-color: #fff
}

to {
	outline-color: #000
}

}
.ace-save-state {
	animation-duration: 10ms;
	-o-animation-duration: 10ms;
	-ms-animation-duration: 10ms;
	-moz-animation-duration: 10ms;
	-webkit-animation-duration: 10ms;
	animation-delay: 0s;
	-o-animation-delay: 0s;
	-ms-animation-delay: 0s;
	-moz-animation-delay: 0s;
	-webkit-animation-delay: 0s;
	animation-name: nodeInserted;
	-o-animation-name: nodeInserted;
	-ms-animation-name: nodeInserted;
	-moz-animation-name: nodeInserted;
	-webkit-animation-name: nodeInserted
}
/* 模态框居中样式 */
 .modal-dialog {
 	top:20%;
 }
</style>
<link rel="stylesheet"
	href="${request.contextPath}/static/assets/css/bsie-paginator.css">
</head>
<body class="skin-2" style="background-color: #FFF;">
	<div class="page-content">
		<div class="tabbable">
			<div class="tab-content">
			   <div id="manage" class="tab-pane active in">
				  <div class="row">
					<div class="col-xs-12">
						<div class="widget-box">
							<div class="widget-body" style="background-color: #EFF3F8;">
								<div class="widget-main">
									<form class="form-inline" id="searchForm" method="post"
										action="${request.contextPath}/datashow/inputProduct">
										<input type="hidden" id="_csrf" name="${_csrf.parameterName}"
											value="${_csrf.token}" />
										<div class="form-group" style="width: 100%;">
											<label  for="exampleInputName">产品ID <input
													class="form-control" name="productId"
													value="<#if LMMCareProductVO??&&LMMCareProductVO.productId??>${LMMCareProductVO.productId}</#if>"
													placeholder="模糊查询产品ID" type="text" style="width: 123px">
											</label>
											<label  for="exampleInputName" style="margin-left: 30px;">产品名称 
												<input class="form-control"
													name="productName"
													value="<#if LMMCareProductVO??&&LMMCareProductVO.productName??>${LMMCareProductVO.productName}</#if>"
													placeholder="模糊查询产品名称" type="text" style="width: 123px">
												</label>
											<label  for="exampleInputName" style="margin-left: 30px;">所属城市 <input class="form-control"
													name="cityName"
													value="<#if LMMCareProductVO??&&LMMCareProductVO.cityName??>${LMMCareProductVO.cityName}</#if>"
													placeholder="模糊查询所属城市" type="text" style="width: 123px"
													style="width:123px">
										    </label>
											<label  for="exampleInputName" style="margin-left: 30px;">业务编码
												<select name="businessCode"
													id="businessCodeSearch" aria-controls="dynamic-table"
													class="form-control input-sm" style="width: 80px;height:34px">
														<#if
														LMMCareProductVO??&&LMMCareProductVO.businessCode??&&LMMCareProductVO.businessCode=="TICKET">
														<option value="TICKET" selected>门票</option><#else>
														<option value="TICKET">门票</option></#if> <#if
														LMMCareProductVO??&&LMMCareProductVO.businessCode??&&LMMCareProductVO.businessCode=="HOTEL">
														<option value="HOTEL" selected>酒店</option><#else>
														<option value="HOTEL">酒店</option></#if>
												</select>
											</label>
											<label  for="exampleInputName" style="margin-left: 30px;">公司编码
												<select name="companyCode"
													id="companyCodeSearch" aria-controls="dynamic-table"
													class="form-control input-sm" style="width: 80px;height:34px">
														<#if companyCode??&&companyCode=="xc">
														<option value="xc" selected>XC</option><#else>
														<option value="xc">XC</option></#if> <#if
														companyCode??&&companyCode=="tn">
														<option value="tn" selected>TN</option><#else>
														<option value="tn">TN</option></#if> 
														<#if LMMCareProductVO??&&LMMCareProductVO.businessCode??&&LMMCareProductVO.businessCode=="TICKET">
														<#if companyCode??&&companyCode=="tc">
														<option value="tc" selected>TC</option><#else>
														<option value="tc">TC</option></#if>
														<#if companyCode??&&companyCode=="mt">
														<option value="mt" selected>MT</option>
														<#else><option value="mt">MT</option></#if>
														 </#if>
														 <#if companyCode??&&companyCode=="qnr">
														<option value="qnr" selected>QNR</option><#else>
														<option value="qnr">QNR</option></#if> <#if
														LMMCareProductVO??&&LMMCareProductVO.businessCode??&&LMMCareProductVO.businessCode=="HOTEL"><#if
														companyCode??&&companyCode=="el">
														<option value="el" selected>EL</option><#else>
														<option value="el">EL</option></#if></#if>
												</select>
											</label>
											<button type="submit" class="btn btn-pink btn-sm" id="search"  style="margin-left: 30px;">
												<span class="ace-icon fa fa-search icon-on-right bigger-110"></span>查询
											</button>
											<!--  
											<a class="green"  
												role="button" data-toggle="modal" data-target="#myModal03">
												<button type="submit" class="btn btn-pink btn-sm"
													id="newCareProduct" onclick="addNewCareProduct();">
													<span class="ace-icon fa icon-on-right bigger-110"></span>
													新增
												</button>
											</a>-->
								</div>
									</form>	
								</div>
							</div>
						</div>
					</div>
					<div class="col-xs-12">
						<table id="dynamic-table"
							class="table table-striped table-bordered table-hover dataTable no-footer"
							role="grid" aria-describedby="dynamic-table_info">
							<thead>
								<tr>
									<th>产品ID</th>
									<th>产品名称</th>
									<th>公司编码</th>
									<th>城市</th>
									<th>最低价</th>
									<th>评分</th>
									<!--  
									<th>销量</th>
									<th>星级</th>-->
									<th>抓取时间</th>
									<th>任务编码</th>
									<th>产品地址</th>
									<th>详情链接</th>
									<th>快照</th>
									<th>操作</th>
									<th>商品补录</th>
								</tr>
							</thead>
							<tbody>
								<#if prodList?? && prodList?size&gt;0> <#list prodList as
								prod>
								<tr class="${prod.id!}">
									<td class="tdproductId">${prod.productId!}</td>
									<td class="tdsceneryName">${prod.sceneryName!}</td>
									<td class="tdcompanyCode">${prod.companyCode!}</td>
									<td class="${prod.cityCode!}">${prod.cityName!}</td>
									<td class="tdlowestPrice">${prod.lowestPrice!}</td>
									<td class="tdscore">${prod.score!}</td>
									<!-- 
									<td class="tdsaleCount">${prod.saleCount!}</td>
									<td class="tdstarLevel">${prod.starLevel!}</td> -->
									<td class="tdcreateTime"><#if
										prod.createTime??>${prod.createTime?string('yyyy-MM-dd')}</#if></td>
									<td class="tdtaskId">${prod.taskId!}</td>
									<td class="tdsceneryAddr">${prod.sceneryAddr!}</td>
									<td class="tddetailUrl"><#if
										prod.detailUrl??&&prod.detailUrl?length&gt;10>${prod.detailUrl?substring(0,10)}...<a
										onclick="showDetailUrl(this);" class="${prod.detailUrl}"><i class="ace-icon fa fa-eye"></i></a><#elseif
										prod.detailUrl??>${prod.detailUrl}</#if>
									</td>
									<td class="tdsnapshotAddr"><#if
										prod.snapshotAddr??&&prod.snapshotAddr?length&gt;10>${prod.snapshotAddr?substring(0,10)}...<a
										onclick="showDetailUrl(this);" class="${prod.snapshotAddr}"><i class="ace-icon fa fa-eye"></i></a><#elseif
										prod.snapshotAddr??>${prod.snapshotAddr}</#if>
									</td>
									<td style='cursor:pointer;' onclick="updateInputProduct(this);" data-toggle="modal" data-target="#myModal01">
										<a class="green"
										role="button" >
											<i class="ace-icon fa fa-pencil bigger-130"></i>
										</a> 
										<!-- 
										<a class="red" onclick="deleteInputProduct(this);" role="button">
											<i class="ace-icon fa fa-trash-o bigger-130"></i>
										</a> -->
									</td>
									<td style='cursor:pointer;' onclick="skipToInputCommodity(this);">
									<a class="blue" >
											<i class="ace-icon fa fa-search-plus bigger-130"></i>
									</a></td>
								</tr>
								</#list> </#if>
							</tbody>
						</table>
						<#include "paginator.html">
					</div>
					</div>
				</div>

				<!-- 链接弹窗 -->
				<div class="row">
					<div class="col-xs-12">
						<button class="btn btn-info" data-toggle="modal" type="button"
							style="display: none;" id="showProductDetailUrl"
							data-target="#myModal02"></button>
						<div class="modal fade" id="myModal02" tabindex="-1" role="dialog"
							aria-labelledby="myModalLabel" aria-hidden="true">
							<div class="modal-dialog">
								<div class="modal-content" style="width: 800px; height: 250px">
									<div class="modal-header">
										<button type="button" class="close" data-dismiss="modal"
											aria-hidden="true">×</button>
										<h4 class="modal-title" id="detailUrlTitle">
											<strong>详情链接</strong>
										</h4>
									</div>
									<div class="modal-body" id="productUrlDetail"
										style='word-break: break-all;'></div>
								</div>
								<!-- /.modal-content -->
							</div>
							<!-- /.modal -->
						</div>
					</div>
				</div>
				<!-- 更新产品 -->
				<div class="row">
					<div class="col-xs-12">
						<button class="btn btn-info" data-toggle="modal" type="button"
							style="display: none;" id="updateProduct"
							data-target="#myModal01"></button>
						<form id="updateCode" class="form-horizontal" role="form"
							method='post'>
							<input type="hidden" id="_csrf" name="${_csrf.parameterName}"
								value="${_csrf.token}" />
							<div class="modal fade" id="myModal01" tabindex="-1"
								role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
								<div class="modal-dialog">
									<div class="modal-content">
										<div class="modal-header">
											<button type="button" class="close" data-dismiss="modal"
												aria-hidden="true">×</button>
											<h4 class="modal-title" id="myModalLabel">产品编辑</h4>
										</div>
										<div class="modal-body">

											<div class="space-4"></div>
											<div class="form-group">
												<div class="col-sm-9">
													<input type="hidden" name="id" id="productTableId" />
													<div class="form-group">
														<label class="col-sm-3 control-label no-padding-right"
															for="form-field-1">产品ID</label>

														<div class="col-sm-9">
															<input type="text" id="productId" name="productId"
																placeholder="产品ID" class="form-control" readonly>
														</div>
													</div>
													<div class="form-group">
														<label class="col-sm-3 control-label no-padding-right"
															for="form-field-1">产品名称</label>

														<div class="col-sm-9">
															<input type="text" id="sceneryName" name="sceneryName"
																placeholder="产品名称" class="form-control" readonly>
														</div>
													</div>
													<input type="hidden" id="companyCode" name="companyCode">
													<!-- 
													<div class="form-group">
														<label class="col-sm-3 control-label no-padding-right"
															for="form-field-1">公司编码 </label>

														<div class="col-sm-9">
															<input type="text" id="companyCode" name="companyCode"
																placeholder="公司编码" class="form-control" readonly>
														</div>
													</div> -->
													<div class="form-group">
														<label class="col-sm-3 control-label no-padding-right"
															for="form-field-1">城市 </label>

														<div class="col-sm-9">
															<input type="text" id="cityName" name="cityName"
																placeholder="城市" class="form-control" >
															<input type="hidden" id="cityCode" name="cityCode"/>
														</div>
													</div>
													<div class="form-group">
														<label class="col-sm-3 control-label no-padding-right"
															for="form-field-1">最低价</label>

														<div class="col-sm-9">
															<input type="text" id="lowestPrice" name="lowestPrice"
																placeholder="最低价" class="form-control" >
														</div>
													</div>

													<div class="form-group">
														<label class="col-sm-3 control-label no-padding-right"
															for="form-field-1">评分</label>

														<div class="col-sm-9">
															<input type="text" id="score" name="score"
																placeholder="评分" class="form-control">
														</div>
													</div>
													
													<div class="form-group">
														<label class="col-sm-3 control-label no-padding-right"
															for="form-field-1">抓取时间</label>

														<div class="col-sm-9">
															<input type="text" id="createTime" name="createTime"
																placeholder="抓取时间" class="form-control">
														</div>
													</div>
													<div class="form-group">
														<label class="col-sm-3 control-label no-padding-right"
															for="form-field-1">任务编码</label>

														<div class="col-sm-9">
															<input type="text" id="taskId" name="taskId"
																placeholder="任务编码" class="form-control">
														</div>
													</div>
													<div class="form-group">
														<label class="col-sm-3 control-label no-padding-right"
															for="form-field-1">产品地址</label>

														<div class="col-sm-9">
															<input type="text" id="sceneryAddr" name="sceneryAddr"
																placeholder="产品地址" class="form-control">
														</div>
													</div>
													<div class="form-group">
														<label class="col-sm-3 control-label no-padding-right"
															for="form-field-1">详情链接</label>

														<div class="col-sm-9">
															<input type="text" id="detailUrl" name="detailUrl"
																placeholder="详情链接" class="form-control" readonly>
														</div>
													</div>
													<div class="form-group">
														<label class="col-sm-3 control-label no-padding-right"
															for="form-field-1">快照</label>

														<div class="col-sm-9">
															<input type="text" id="snapshotAddr" name="snapshotAddr"
																placeholder="快照" class="form-control">
														</div>
													</div>
												</div>
											</div>
										</div>
										<div class="modal-footer">
											<button type="button" class="btn btn-pink btn-sm"
												data-dismiss="modal">关闭</button>
											<button type="button" class="btn btn-pink btn-sm"
												id="submitInputProductUpdate" data-dismiss="modal">
												提交</button>
										</div>
									</div>
									<!-- /.modal-content -->
								</div>
								<!-- /.modal -->
							</div>
						</form>
					</div>
				</div>

			</div>
		</div>
	</div>
	<input type="hidden" id="prodConfigContext"
		value="${request.contextPath}" />
	<script type="text/javascript">
		if ('ontouchstart' in document.documentElement)
			document
					.write("<script src='${request.contextPath}/static/assets/js/jquery.mobile.custom.min.js'>"
							+ "<"+"/script>");
	</script>
	<script src="${request.contextPath}/static/assets/js/bootstrap.min.js"></script>
	<script src="${request.contextPath}/static/assets/js/jquery-ui.min.js"></script>
	<script src="${request.contextPath}/static/assets/js/bootbox.js"></script>
	<script src="${request.contextPath}/static/assets/js/spin.js"></script>
	<!-- ace scripts -->
	<script
		src="${request.contextPath}/static/assets/js/ace-elements.min.js"></script>
	<script src="${request.contextPath}/static/assets/js/ace.min.js"></script>
	<!-- validator scripts -->
	<script
		src="${request.contextPath}/static/assets/js/bootstrapValidator.min.js"></script>
	<!-- user scripts -->
	<script src="${request.contextPath}/static/assets/js/user/base.js"></script>
	<script type="text/javascript">
		prodConfigContext = $("#prodConfigContext").val();
		$("input[name=createTime]").datepicker({
			dateFormat : "yy-mm-dd",
			autoclose : true
		});
		$("input[name=insertTime]").datepicker({
			dateFormat : "yy-mm-dd",
			autoclose : true
		});
		var showDetailUrl = function(obj) {
			title = $(obj).parent().attr("class");
			url = $(obj).attr('class');
			$("#detailUrlTitle").text("");
			if (title == "tddetailUrl") {
				$("#detailUrlTitle").append("<strong>详情链接</strong>");
			}
			if (title == "tdsnapshotAddr") {
				$("#detailUrlTitle").append("<strong>快照</strong>");
			}
			$("#productUrlDetail").text("");
			$("#productUrlDetail").text(url);
			$("#showProductDetailUrl").click();
		}
		var updateInputProduct = function(obj) {
			tid = $(obj).parents("tr").attr("class");
			productId = $(obj).parents("tr").find(".tdproductId").text();
			sceneryName = $(obj).parents("tr").find(".tdsceneryName").text();
			companyCode = $(obj).parents("tr").find(".tdcompanyCode").text();
			cityCode = $(obj).parents("tr").find(".tdcompanyCode").next().attr("class");
			cityName= $(obj).parents("tr").find(".tdcompanyCode").next().text();
			lowestPrice = $(obj).parents("tr").find(".tdlowestPrice").text();
			score = $(obj).parents("tr").find(".tdscore").text();
			createTime = $(obj).parents("tr").find(".tdcreateTime").text();
			taskId = $(obj).parents("tr").find(".tdtaskId").text();
			sceneryAddr = $(obj).parents("tr").find(".tdsceneryAddr").text();
			detailUrl = $(obj).parents("tr").find(".tddetailUrl a").attr(
					"class");
			snapshotAddr = $(obj).parents("tr").find(".tdsnapshotAddr a").attr(
					"class");
			if(snapshotAddr==null){
				snapshotAddr=$(obj).parents("tr").find(".tdsnapshotAddr").text();
			}
			$("#productTableId").val(tid);
			$("#productId").val(productId);
			$("#sceneryName").val(sceneryName);
			$("#companyCode").val(companyCode);
			$("#cityCode").val(cityCode);
			$("#cityName").val(cityName);
			$("#lowestPrice").val(lowestPrice);
			$("#score").val(score);
			$("#createTime").val(createTime);
			$("#taskId").val(taskId);
			$("#sceneryAddr").val(sceneryAddr);
			$("#detailUrl").val(detailUrl);
			$("#snapshotAddr").val(snapshotAddr);
		}
		$("#submitInputProductUpdate")
				.click(
						function() {
							//异步提交到后台
							$
									.ajax({
										url : prodConfigContext
												+ '/datashow/updateInputProduct',
										type : "GET",
										data : {
											id : tid,
											//productId : $("#productId").val(),
											//sceneryName : $("#sceneryName").val(),
											companyCode : $("#companyCode")
													.val(),
											cityCode : $("#cityCode").val(),
											lowestPrice : $("#lowestPrice")
													.val(),
											score : $("#score").val(),
											createTime : $("#createTime").val(),
											taskId : $("#taskId").val(),
											sceneryAddr : $("#sceneryAddr")
													.val(),
											//detailUrl : $("#detailUrl").val(),
											snapshotAddr : $("#snapshotAddr")
													.val(),
											cityName : $("#cityName").val(),
											businessCode:$("#businessCodeSearch").val()
										},
										success : function(data) {
											if(data.sessionStatus==540){//异步请求session过期状态
												window.location.href=prodConfigContext+"/login";
												//location.href="show_product?prodId="+prod_id+"&sceneryName="+tdSceneryName+"&pageNum="+$("#pageNum").val();
												return;
											}else{
												if(data.cityError!=null){
													bootbox.alert("请输入正确的城市名！");
												}else{
													location.reload();
													bootbox.alert("更新成功！");
													
												}
											}
											
										}
									});
						})
		/*
		var deleteInputProduct = function(obj) {
			tid = $(obj).parents("tr").attr("class");
			companyCode = $(obj).parents("tr").find(".tdcompanyCode").text();
			bootbox
					.confirm(
							"<strong style='font-size:15px;padding-left:150px'>是否确认删除？</strong>",
							function(result) {
								if (result) {
									$
											.ajax({
												url : prodConfigContext
														+ '/datashow/deleteInputProduct',
												type : "GET",
												data : {
													id : tid,
													companyCode : companyCode
												},
												success : function(data) {
													$(obj).parents("tr").remove();
												}
											});
								}
							});
		};
		*/
		var selectCityName = function() {
			$.ajax({
				url : prodConfigContext + '/backConfig/getCityCode',
				type : "GET",
				data : {
					cityName : ncityName
				},
				success : function(data) {
					if(data.sessionStatus==540){//异步请求session过期状态
						window.location.href=prodConfigContext+"/login";
						return;
					}else{
						if (data.cityCodes != null && data.cityCodes.size() > 0) {
							$.each(data.cityCodes, function(n, value) {
							})
							$("#ncityCode").val(data.cityCode);
							$("#ncityName").append("<option></option>")
						}
					}
					

				}
			});
		}
		var skipToInputCommodity=function(obj){
			productId=$(obj).parents("tr").find(".tdproductId").text().trim();
			sceneryName=$(obj).parents("tr").find(".tdsceneryName").text().trim();
			companyCode=$(obj).parents("tr").find(".tdcompanyCode").text().trim();
			businessCode=$("#businessCodeSearch").val();
			if(productId==null||productId.length==0||sceneryName==null||sceneryName.length==0){
				bootbox.alert("<strong style='padding-left:200px'>请先输入产品信息</strong>");
			}else{
				location.href=prodConfigContext+"/datashow/inputCommodity?productId="+productId+"&sceneryName="+sceneryName+"&prodPageNum="+$("#prodPageNum").val()+"&companyCode="+companyCode+"&businessCode="+businessCode;
			}
			
		}
	</script>
</body>
</html>